﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AppUpgrader
{
    public delegate void StateChangedEvent(Object sender, StateChangedEventArgs arg);
    public delegate void ExceptionEvent(Object sender, Exception ex);
    public abstract class AbstractWorker
    {
        public event StateChangedEvent StateChanged;
        public event StateChangedEvent Complete;
        public event ExceptionEvent ExceptionOccured;

        protected virtual void RaiseStateChanged(StateChangedEventArgs arg)
        {
            if (this.StateChanged != null)
                StateChanged(this, arg);
        }
        protected virtual void RaiseComplete(StateChangedEventArgs arg)
        {
            if (this.Complete != null)
                Complete(this, arg);
        }
        protected virtual void RaiseException(Exception ex)
        {
            if (this.ExceptionOccured != null)
                ExceptionOccured(this, ex);
        }
    }
    public class StateChangedEventArgs : EventArgs
    {
        public int Percent { get; set; }
        public String Message { get; set; }
    }
}
